package com.ruoyi.web.controller.degree;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.degree.domain.BizSchoolsMentors;
import com.ruoyi.degree.service.IBizSchoolsMentorsService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 管家留言Controller
 * 
 * @author Polly
 * @date 2025-08-24
 */
@RestController
@RequestMapping("/degree/mentors")
public class BizSchoolsMentorsController extends BaseController
{
    @Autowired
    private IBizSchoolsMentorsService bizSchoolsMentorsService;

    /**
     * 查询管家留言列表
     */
    @PreAuthorize("@ss.hasPermi('degree:mentors:list')")
    @GetMapping("/list")
    public TableDataInfo list(BizSchoolsMentors bizSchoolsMentors)
    {
        startPage();
        List<BizSchoolsMentors> list = bizSchoolsMentorsService.selectBizSchoolsMentorsList(bizSchoolsMentors);
        return getDataTable(list);
    }

    /**
     * 导出管家留言列表
     */
    @PreAuthorize("@ss.hasPermi('degree:mentors:export')")
    @Log(title = "管家留言", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, BizSchoolsMentors bizSchoolsMentors)
    {
        List<BizSchoolsMentors> list = bizSchoolsMentorsService.selectBizSchoolsMentorsList(bizSchoolsMentors);
        ExcelUtil<BizSchoolsMentors> util = new ExcelUtil<BizSchoolsMentors>(BizSchoolsMentors.class);
        util.exportExcel(response, list, "管家留言数据");
    }

    /**
     * 获取管家留言详细信息
     */
    @PreAuthorize("@ss.hasPermi('degree:mentors:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(bizSchoolsMentorsService.selectBizSchoolsMentorsById(id));
    }

    /**
     * 新增管家留言
     */
    @PreAuthorize("@ss.hasPermi('degree:mentors:add')")
    @Log(title = "管家留言", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody BizSchoolsMentors bizSchoolsMentors)
    {
        //获取1-5之间的随机数
        bizSchoolsMentors.setAvatar((int)(Math.random()*5));
        return toAjax(bizSchoolsMentorsService.insertBizSchoolsMentors(bizSchoolsMentors));
    }

    /**
     * 修改管家留言
     */
    @PreAuthorize("@ss.hasPermi('degree:mentors:edit')")
    @Log(title = "管家留言", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody BizSchoolsMentors bizSchoolsMentors)
    {
        return toAjax(bizSchoolsMentorsService.updateBizSchoolsMentors(bizSchoolsMentors));
    }

    /**
     * 删除管家留言
     */
    @PreAuthorize("@ss.hasPermi('degree:mentors:remove')")
    @Log(title = "管家留言", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(bizSchoolsMentorsService.deleteBizSchoolsMentorsByIds(ids));
    }
}
